#ifndef _GAME_H_
#define _GAME_H_

#include "input.h"
#include "igamestate.h"
#include "gameinfo.h"
#include "gamemodel.h"
#include "gameview.h"
#include "guisystem.h"

class GameStateManager;

enum TurnResult
{
    //TR_NONE = 0,
    TR_CONTINUE = 0,
    TR_PROMOTION,
    TR_WHITEWON,
    TR_BLACKWON,
    TR_STALEMATE
};

class Game : public IGameState
{
public:
    Game(GameStateManager& gsm, GameInfo& gameInfo);
    ~Game();

    bool update(float dt, const Input& input);
    IGameStateView& getView();
    void onEnter();

    void reset();

private:

    void handleCameraInput(const Input& input);

    TurnResult playHumanTurn(const Input& input);
    TurnResult playAiTurn();

    GameStateManager& _gsm;

    GameModel& _model;
    GameInfo& _gameInfo;
    GuiSystem& _gui;
    GameView& _view;

    static const GuiId GUI_HOURGLASS = 999;
    static const GuiId GUI_WHITEWON = 998;
    static const GuiId GUI_BLACKWON = 997;

    bool _pieceSelected;
    int _selPieceX, _selPieceY;

    bool _promotionDone, _delayedPromotion;

    bool _gameEnded;

};

#endif // _GAME_H_
